package com.cl.security.system.controller;

import com.cl.security.common.result.CommonResult;
import com.cl.security.common.util.FileUtil;
import com.cl.security.system.service.FileInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("file")
public class FileController {
    @Autowired
    private FileInfoService fileInfoService;
    @GetMapping("get/{fileName}")
    public void get(@PathVariable("fileName") String fileName, HttpServletResponse response) {
        FileUtil.get(fileName,response);
    }
    @PostMapping("upload")
    public CommonResult upload(MultipartFile file) {
        return fileInfoService.upload(file);
    }
}
